package com.sina.finance.api.framework.validator;

/**
 * @File name : ConditionException
 * @Description :
 * @Creator : cuiyong
 * @CreateTime : 15/10/14 上午11:28
 * @Version : 1.0
 * @Update records:
 * 1.0 15/10/14 by cuiyong: Created
 * All rights served : SINA Corporation
 */
public class BusinessException extends RuntimeException {
    protected String code;

    private String message;

    /**
     * 可以展示给外部的信息
     */
    private String outerMsg;

    /**
     * 内部存储的完整信息为outerMsg+moreMsg
     */
    private String moreMsg;


    private static final long serialVersionUID = -2029130477461261042L;

    public BusinessException(final String code, final String outerMsg, String moreMsg, final Throwable cause){
        super(outerMsg + " " + moreMsg,cause);
        this.message = outerMsg + " " + moreMsg;
        this.outerMsg = outerMsg;
        this.moreMsg = moreMsg;
        this.code = code;
    }

    public BusinessException(final String code, final String outerMsg, String moreMsg){
        super(outerMsg + " " + moreMsg);
        this.message = outerMsg + " " + moreMsg;
        this.outerMsg = outerMsg;
        this.moreMsg = moreMsg;
        this.code = code;
    }

    public BusinessException(final String code, final String message, final Throwable cause){
        super(message,cause);
        this.message = message;
        this.outerMsg = message;
        this.code = code;
    }

    public BusinessException(final String code, final String message){
        super(message);
        this.message = message;
        this.outerMsg = message;
        this.code = code;
    }

    @Override
    public String getLocalizedMessage() {
        return this.message;
    }

    public String getCode() {
        return code;
    }

    public String getOuterMsg() {
        return outerMsg;
    }

    public String getMoreMsg() {
        return moreMsg;
    }
}
